#include <stdlib.h>
#include <iostream>
#include "InputServerParams.h"
#include "Config.h"

InputServerParams::InputServerParams()
{
  this->_port = DEFAULT_PORT;
  this->initLinkInput();
}

void InputServerParams::initLinkInput()
{
  this->_linkInput["-p"] = &InputServerParams::bindPort;
}

void InputServerParams::bindPort(int index)
{
  if (this->_argc > index + 1)
    this->_port = atoi(this->_argv[index + 1]);
}

void InputServerParams::parseInput(int argc, char **argv)
{
  this->_argc = argc;
  this->_argv = argv;
  for (int i = 0; i < argc; ++i)
    {
      if (this->_linkInput.count(argv[i]))
	(this->*this->_linkInput[argv[i]])(i);
    }
}
